class_name 下毒
extends Node2D

@onready var life_timer: Timer = $LifeTimer
@onready var hitbox_component: HitboxComponent = $HitboxComponent
@onready var animation_player: AnimationPlayer = $AnimationPlayer

var source_peer_id: int
var damage: int = 0



func _ready() -> void:
	hitbox_component.damage = damage
	hitbox_component.source_peer_id = source_peer_id
	hitbox_component.hit_hurtbox.connect(_on_hit_hurtbox)
	life_timer.timeout.connect(_on_life_timer_timeout.bind())



func register_collision():
	#hitbox_component.is_hit_handled = true
	animation_player.play("attack")
	

func  _on_life_timer_timeout():
	if is_multiplayer_authority():
		queue_free()

func _on_hit_hurtbox(_hurtbox_component: HurtboxComponent):
	register_collision()
